Skip to content

Conversation

@dfcoffin
Copy link
Contributor

Summary

Convert LineItem from UUID to Long ID with IDENTITY generation per ESPI 4.0 XSD specification (espi.xsd:1449). LineItem extends Object (not IdentifiedObject), requiring Long ID with vendor-specific auto-increment syntax.

Key Changes:

  • LineItemEntity: Converted from UUID to Long ID with GenerationType.IDENTITY
  • Added missing XSD fields: measurement (SummaryMeasurement), itemKind (required), unitCost, itemPeriod (DateTimeInterval)
  • LineItemRepository: Changed from JpaRepository<LineItemEntity, UUID> to JpaRepository<LineItemEntity, Long>
  • Query optimization: Removed 10 non-indexed queries, retained 2 indexed queries (findAllIds, findAllByUsageSummaryId)
  • DTO/Mapper layer: Created LineItemDto, LineItemMapper, and SummaryMeasurementMapper
  • Database migrations: Moved usage_summaries table from V3 to V2 vendor-specific files to maintain proper dependency order
  • Comprehensive tests: Rewrote LineItemRepositoryTest with full coverage (CRUD, queries, relationships, business logic, persistence)

Migration Strategy:

  • Added line_items table to V2 vendor-specific migrations with auto-increment (BIGINT AUTO_INCREMENT for MySQL/H2, BIGSERIAL for PostgreSQL)
  • Moved usage_summaries + usage_summary_related_links from V3 to V2 to resolve Flyway dependency order (line_items FK requires usage_summaries to exist first)

Test plan

  • All 533 tests pass
  • LineItemRepositoryTest: 9 tests covering CRUD operations, custom queries, relationships, business logic, and persistence
  • UsageSummaryRepositoryTest: Fixed to include required itemKind field (19 tests pass)
  • Flyway migrations validated across all databases (MySQL, PostgreSQL, H2)
  • Integration tests pass with TestContainers (MySQL, PostgreSQL)
  • Code compiles successfully with MapStruct processing

Files Changed:

  • Modified: LineItemEntity.java, LineItemRepository.java
  • Created: LineItemDto.java, LineItemMapper.java, SummaryMeasurementMapper.java
  • Modified: V2 vendor-specific migrations (MySQL, PostgreSQL, H2)
  • Modified: V3 migration (removed usage_summaries, added comments)
  • Modified: LineItemRepositoryTest.java (complete rewrite)
  • Modified: UsageSummaryRepositoryTest.java (added itemKind field)

🤖 Generated with Claude Code

Convert LineItem from UUID to Long ID with IDENTITY generation per ESPI 4.0
XSD (espi.xsd:1449). LineItem extends Object, not IdentifiedObject, requiring
Long ID with vendor-specific auto-increment syntax.

Changes:
- LineItemEntity: Change ID from UUID to Long with GenerationType.IDENTITY
- Add missing XSD fields: measurement (SummaryMeasurement), itemKind (required),
  unitCost, itemPeriod (DateTimeInterval)
- LineItemRepository: Change from JpaRepository<LineItemEntity, UUID> to Long
- Remove 10 non-indexed queries, keep 2 indexed queries
- Create LineItemDto record matching XSD structure (no id/uuid fields)
- Create LineItemMapper interface with toDto/toEntity mappings
- Create SummaryMeasurementMapper for measurement field mapping
- LineItemRepositoryTest: Complete rewrite with comprehensive coverage
  (CRUD, custom queries, relationships, business logic, persistence)
- Move usage_summaries + usage_summary_related_links tables from V3 to V2
  vendor-specific migrations to maintain dependency order (line_items FK
  requires usage_summaries to exist first)
- Fix UsageSummaryRepositoryTest to include required itemKind field

Database migrations:
- Add line_items table to V2 vendor-specific files with auto-increment
  (BIGINT AUTO_INCREMENT for MySQL/H2, BIGSERIAL for PostgreSQL)
- Move usage_summaries from V3 to V2 (before line_items) to resolve
  Flyway migration order issue

All 533 tests pass.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@dfcoffin dfcoffin merged commit 8e519f7 into main Jan 13, 2026
5 checks passed
@dfcoffin dfcoffin deleted the feature/schema-compliance-phase-10-line-item branch January 13, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants